f1='APPAVAIL'
F2='APPOINT'
F11='AVAIL_D'
F12='AVAIL_S'
F21='APPODOC'
F22='APPOPAT'
SELE 1
SET EXCLU ON
USE &DR1&F1
DO WHILE .NOT. EOF()
   IF DATE_SLOT<DATE()
      IF REC_LOCK(0)
         DELE
      ENDIF
      UNLOCK
   ENDIF
   SKIP
ENDDO
IF NET_USE('&DR1&F1',.T.,'1',10)
   PACK
   INDEX ON DTOS(DATE_SLOT)+DOC_CODE+TIME_SLOT TO &DR1&F1
   INDEX ON DOC_CODE+DTOS(DATE_SLOT)+TIME_SLOT TO &DR1&F11
   INDEX ON DTOS(DATE_SLOT)+DOC_SPEC+DOC_CODE+TIME_SLOT TO &DR1&F12
ENDIF
CLOS ALL
SELE 1
SET EXCLU ON
USE &DR1&F2
DO WHILE .NOT. EOF()
   IF DAT_APP<DATE()
      IF REC_LOCK(0)
         DELE
      ENDIF
      UNLOCK
   ENDIF
   SKIP
ENDDO
IF NET_USE('&DR1&F2',.T.,'1',10)
   PACK
   INDEX ON DTOS(DAT_APP)+DR_APP+HOUR_APP TO &DR1&F2
   INDEX ON DR_APP+DTOS(DAT_APP)+HOUR_APP TO &DR1&F21
   INDEX ON PAT_NAME+PAT_F_NAME+DTOS(DAT_APP) TO &DR1&F22
ENDIF
CLOS ALL
